import React, { Component } from 'react';
import PropTypes from "prop-types";
import {
    Form,
    Input
} from "antd";

const Item = Form.Item


// 添加分类的form组件
export default class AddForm extends Component {
    // ref 
    addRef = React.createRef();

    componentDidMount() {
        this.props.setAddForm(this.addRef);
    }


    static propTypes = {
        setAddForm: PropTypes.func.isRequired, // 用来传递form对象的函数
    }

    render() {
        const formItemLayout = {
            labelCol: {span: 4},
            wrapperCol: {span: 15},
        }

        return (
            <Form ref={ this.addRef } {...formItemLayout}>
                <Item
                label="角色名称:" 
                name="roleName"  
                rules={[
                    {
                        required: true,
                        message: "角色名称必须输入",
                    },
                ]} 
                >
                    <Input placeholder="请输入角色名称" />
                </Item>
            </Form>
        )
    }
}


